package com.quaidi.smartlocker.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quaidi.smartlocker.entity.ExpressPackage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 快递包裹Mapper接口
 * 
 * @author QuaiDi
 * @since 2025-08-26
 */
@Mapper
public interface ExpressPackageMapper extends BaseMapper<ExpressPackage> {

    /**
     * 根据取件码和收件人电话查找包裹
     */
    @Select("SELECT * FROM express_package WHERE pickup_code = #{pickupCode} AND recipient_phone = #{recipientPhone} AND deleted = 0")
    ExpressPackage findByPickupCodeAndPhone(@Param("pickupCode") String pickupCode, @Param("recipientPhone") String recipientPhone);

    /**
     * 仅根据取件码查找包裹
     */
    @Select("SELECT * FROM express_package WHERE pickup_code = #{pickupCode} AND deleted = 0")
    ExpressPackage findByPickupCode(@Param("pickupCode") String pickupCode);

    /**
     * 根据快递单号查找包裹
     */
    @Select("SELECT * FROM express_package WHERE tracking_number = #{trackingNumber} AND deleted = 0")
    ExpressPackage findByTrackingNumber(@Param("trackingNumber") String trackingNumber);
}